-
Notifications
You must be signed in to change notification settings - Fork 21
feat: add stats tracking for pacote.extract #618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: add stats tracking for pacote.extract #618
Conversation
🦋 Changeset detectedLatest commit: e985c9f The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
workspaces/scanner/src/depWalker.ts
Outdated
| spec, | ||
| registry | ||
| registry, | ||
| extractFn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would just inline the operation and rename the extractFn to pacoteProvider:
{
pacoteProvider:(spec: string, dest: string, opts: pacote.Options) => statsCollector.track(
`pacote.extract ${spec}`,
() => pacote.extract(spec, dest, opts)
)
}
workspaces/tarball/src/tarball.ts
Outdated
| }; | ||
| } | ||
|
|
||
| type ExtractFunction = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would rename it PacoteProvider and use an interface with the method extract
workspaces/scanner/src/depWalker.ts
Outdated
| ref: any; | ||
| statsCollector: StatsCollector; | ||
| extractFn?: (spec: string, dest: string, opts: pacote.Options) => Promise<void>; | ||
| pacoteProvider?: import("@nodesecure/tarball").PacoteProvider; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s more readable to import the type at the top of the file
workspaces/scanner/src/depWalker.ts
Outdated
| pacoteProvider: { | ||
| extract: async(spec: string, dest: string, opts: pacote.Options) => { | ||
| await statsCollector.track( | ||
| `pacote.extract[${spec}]`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pacote.extract[${spec}] -> pacote.extract ${spec}
It’s the same pattern in the two other examples
workspaces/scanner/src/depWalker.ts
Outdated
| registry, | ||
| statsCollector, | ||
| extractFn: trackedExtract | ||
| pacoteProvider: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably just build the the object once and reuse the same, and not building a new one for each scan
02daaed to
3483f28
Compare
workspaces/scanner/src/depWalker.ts
Outdated
|
|
||
| const pacoteProvider: PacoteProvider = { | ||
| extract: async(spec, dest, opts) => { | ||
| await statsCollector.track( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don’t need the async await syntax since you don’t need the awaited result in this function
This PR adds lightweight stats tracking for
pacote.extractby injecting a tracked extract function.This helps identify slow package extractions and potential bottlenecks during scans.
No breaking changes - existing code works as-is.
Closes #615